<template>
  <div class="publicBox" id="terminalNewbuildCss">

<el-form ref="form"  class="demo-form-inline publicEditFrom" label-width="180px" label-position="left">

<el-row>
               <p class="pubPageTagP">终端设备管理/新建</p>
</el-row>

<el-row>
         <el-form-item label="设备ID">
                 <p>{{ruleForm.no}}</p>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="SN">
                <p>{{ruleForm.sn}}</p>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="品牌">
                 <p>{{ruleForm.brandname}}</p>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="型号">
                 <p>{{ruleForm.model}}</p>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="设备名称">
                <p>{{ruleForm.name}}</p>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="供应商">
                <p>{{ruleForm.supplier}}</p>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="绑定通讯模块IMEI">
                 <el-input class="pubSerIpt" v-model="ruleForm.imei"  placeholder="请输入绑定通讯模块IMEI"></el-input>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="绑定设备编码">
                 <el-input class="pubSerIpt" v-model="ruleForm.deviceNo"  placeholder="绑定设备编码"></el-input>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="所在仓库">
            <el-select v-model="ruleForm.warehouseType" filterable  placeholder="全部" class="pubSlt97">
                <el-option
                v-for="item in $warehouse()"
                :key="item.id"
                :label="item.name"
                :value="item.id">
                </el-option>
            </el-select>
       </el-form-item>
</el-row>

<el-row>
         <el-form-item label="所在门店">
           <el-select v-model="ruleForm.storeId" filterable  placeholder="全部" class="pubSlt97">
                <el-option
                v-for="item in shopArray"
                :key="item.id"
                :label="item.name"
                :value="item.id">
                </el-option>
            </el-select>
       </el-form-item>
</el-row>

<el-row class="pubSubmitBtn-row">
      <el-form-item>
            <el-button class="pubBtnBlue" @click="editTerminal" type="primary">保存</el-button>
            <el-button class="pubBtnGray" @click="$canCleFn"  type="primary">取消</el-button>
      </el-form-item>
</el-row>

</el-form>
    
  </div>
</template>

<script>
import * as API from "@api/equipmenter.js"

export default {
  components: {


  },
  data() {
    return {
      ruleForm:{},
      shopArray:""
    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {


  },
  // 监控data中的数据变化
  watch: {


 },
  methods: {
     async editTerminal(){       
        await API.editTerminal(this.ruleForm).then(res=>{
                    if(res.IsPositive) this.$message.success({message:"操作成功"})
                    this.$router.go(-1)
        })
     }
  },
  async created() {
    await API.getShop().then(res=>{
      this.shopArray=res.Data.records
    })
     if(Object.keys(this.$route.query).length>0){              //ES6写法, Object.keys(targetObject)  将对象的key作为一个数组返回
                  this.disabledFlag=true        //true代表修改数据
                  let rowData=this.$route.query.data
                  this.ruleForm={
                            id:rowData.id,
                            model:rowData.model,
                            no:rowData.no,
                            brandname:rowData.brandname,
                            name:rowData.name,
                            sn:rowData.sn,
                            supplier:rowData.suppliername,
                            imei:rowData.imei,
                            deviceNo:rowData.deviceno,
                            warehouseType:rowData.warehousetype,
                            storeId:rowData.storeid,
              }
        }
  },
  mounted() {


  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='less'>
#terminalNewbuildCss{}

</style>